cd "___YOUR_PATH_HERE___"
use 5_year.dta

***** HAUSMAN TESTS AND HETTEST *************
#delimit ;

qui xtreg d.kaopen_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 l.kaopen_5 counter
  lcrisis_5, fe;
est stor cons;

qui xtreg d.kaopen_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 l.kaopen_5 counter
  lcrisis_5;
est stor eff;

hausman cons eff;
drop _est_cons _est_eff;

xi: qui ivreg2 d.kaopen_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 l.kaopen_5 counter
  (lcrisis_5 =  listar_5 distar_5) i.iso_num;
ivhettest;
ivhettest, fitlev;
drop _Iiso_num_32-_Iiso_num_894;



***** MAIN RESULTS (TABLE 2)**********;

#delimit ;
* BASELINE;

qui xtreg lcrisis_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5 
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 counter lkaopen_5 
  listar_5 distar_5 , fe;
est stor mod1;

qui xtivreg2 dkaopen_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 counter lkaopen_5 
  (lcrisis_5 = listar_5 distar_5) , fe; 
est stor mod2;

qui xtivreg2 dckaopen_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5 
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 counter  lckaopen_5 
  (lcrisis_5 = listar_5 distar_5) , fe; 
est stor mod3;

qui xtivreg2 dk3_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5 
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 counter lk3_5 
  (lcrisis_5 = listar_5 distar_5) , fe; 
est stor mod4;

qui xtivreg2 ds_cap_5 cabalance_5 lngdp_ppp2000_5 lngdppc_ppp2000_5 gov_fce_5 growth_gdppc2000_5 
  ln_inf_5 privcred_gdp_5 reserves_imports_5 savings_5 trade_5 peg_5 polity2_5 counter ls_cap_5 
  (lcrisis_5 = listar_5 distar_5) , fe; 
est stor mod5;

esttab mod1 mod2 mod3 mod4 mod5, b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) scalars(idstat idp widstat j jp) label;
esttab mod1 mod2 mod3 mod4 mod5 using table2.csv, b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) 
	scalars(idstat idp widstat j jp) order(lcrisis_5) replace nogap label;

